<template>
    <div class="character" @touchmove="handleTouchMove">
        <div class="body"></div>
        <div class="head">
            <div class="eye"></div>
            <div class="eye" style="left: 40px;"></div>
            <div class="mouth"></div>
        </div>
    </div>
</template>

<script>
export default {
    methods: {
        handleTouchMove(e) {
            const character = this.$refs.character;
            const xAxis = (window.innerWidth / 2 - e.touches[0].pageX) / 10;
            const yAxis = (window.innerHeight / 2 - e.touches[0].pageY) / 10;
            character.style.transform = `rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
        }
    }
}
</script>

<style>
.character {
    width: 200px;
    height: 300px;
    position: relative;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.body {
    width: 200px;
    height: 200px;
    background: linear-gradient(to right, #ff4500, #ff8c00);
    border-radius: 50%;
    position: absolute;
    top: 200px;
    transform: rotateX(45deg);
}

.head {
    width: 100px;
    height: 100px;
    background: linear-gradient(to bottom right, #00bfff, #1e90ff);
    border-radius: 50%;
    position: absolute;
    top: 50px;
    left: 50px;
    transform: rotateY(45deg);
}

.eye {
    width: 20px;
    height: 20px;
    background-color: #000;
    border-radius: 50%;
    position: absolute;
    top: 40px;
    left: 40px;
    transform: translateZ(20px);
}

.mouth {
    width: 40px;
    height: 10px;
    background-color: #000;
    position: absolute;
    top: 60px;
    left: 30px;
    transform: translateZ(20px);
}</style>
